home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header *** Header built automatically - do not edit! ***********
- *
- * (C) Copyright 1993 by Amit Fridman
- *
- * Name .....: Action.c
- * Created ..: Tuesday 14-Dec-93 11:39:36
- * Revision .: 5
- *
- * Date Author Comment
- * ========= ==================== ====================
- * 13-May-94 Amit Fridman v1.05 Preliminary release
- * 15-Apr-94 Amit Fridman v1.04 Beta version complete
- * 24-Mar-94 Amit Fridman v1.03 Added Keys
- * 24-Feb-94 Amit Fridman v1.02
- * 07-Jan-94 Amit Fridman v1.01
- * 14-Dec-93 Amit Fridman Created this file!
- *
- * $Revision Header ********************************************************/
- #define REVISION 5
-
- /* Handle FBase commands */
-
- #include "FBase.h"
- #include "Protos.h"
-
- extern Object *App;
- extern Object *WI_Main,*WI_Contents,*WI_View,*WI_Rename,*WI_Remark,*WI_Match;
- extern Object *WI_Files,*WI_Keys,*WI_KeySearch,*WI_RecKeys,*WI_FileInfo;
- extern Object *LV_Floppies,*LV_Contents,*LV_View,*LV_Files,*LV_FileKeys;
- extern Object *LV_Keys,*LV_KSSrc,*LV_KSDest,*LV_RKSrc,*LV_RKDest;
- extern Object *BT_Delete,*BT_Rename,*BT_ConOK,*BT_ConCancel;
- extern Object *BT_KeysAdd;
- extern Object *ST_Rename,*ST_Remark,*ST_Match,*ST_KeyName;
- extern Object *CM_Case,*CM_Dirs,*CM_Keys,*CM_KeyAnd;
- extern Object *CY_Disks;
- extern Object *TX_FileName,*TX_FileSize,*TX_FileRem;
-
- extern char *CY_Labels[];
-
- extern struct List FloppyList;
-
- extern BOOL DataChanged;
-
- FLOPPY *MainFloppy = NULL;
- FLOPPY *BackupFloppy = NULL;
- RECORD *MainRecord = NULL;
- RECORD *BackupRecord = NULL;
-
- Object *ParentWindow;
-
- STRPTR OldKey;
- BOOL NewFloppy = FALSE;
- BOOL KeysFull = FALSE;
- BOOL AddKey;
- BOOL EditKey;
- LONGBITS CurKeyMask = 0L;
-
- void DoReadFloppy()
- {
- FLOPPY *Floppy,*FList,*Scan;
- RECORD *OldHead,*NewHead;
- ULONG disk;
- LONG Response;
- int i;
- BOOL Exists = FALSE;
-
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- get(CY_Disks,MUIA_Cycle_Active,&disk);
- if (!ReadFloppy(CY_Labels[disk],&Floppy)) {
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- return;
- }
- NewHead=Floppy->HeadRecord;
- FList=(FLOPPY *)FloppyList.lh_Head;
- while ((!Exists) && (((struct Node *)FList)->ln_Succ)) {
- OldHead=FList->HeadRecord;
- if (strcmp(NewHead->FName,OldHead->FName)==0)
- Exists=TRUE;
- else
- FList=(FLOPPY *)(((struct Node *)FList)->ln_Succ);
- }
- if (Exists) {
- Response=MUI_Request(App,NULL,0,"Read","*By Path|By Name| New | No ","Floppy Exists - Update?");
- if (!Response) {
- FreeFloppy(Floppy,FALSE);
- set(WI_Contents,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- return;
- }
- if (Response<3)
- SalvageData(Floppy,FList,Response);
- for (i=0; ; i++) {
- DoMethod(LV_Floppies,MUIM_List_GetEntry,i,&Scan);
- if (Scan==FList) {
- DoMethod(LV_Floppies,MUIM_List_Remove,i);
- break;
- }
- }
- Remove((struct Node*)FList);
- BackupFloppy=FList;
- } else
- BackupFloppy=NULL;
-
- CreateList(LV_Contents,&Floppy->Records);
- set(WI_Contents,MUIA_Window_Open,TRUE);
- MainFloppy=Floppy;
- NewFloppy=TRUE;
- }
-
- void DoAddFloppy()
- {
- if (NewFloppy) {
- AddFloppyInPlace(&FloppyList,(struct Node *)MainFloppy);
- DoMethod(LV_Floppies,MUIM_List_Insert,&MainFloppy,1,MUIV_List_Insert_Sorted);
- NewFloppy=FALSE;
- }
- if (BackupFloppy)
- FreeFloppy(BackupFloppy,FALSE);
- set(WI_Contents,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- DataChanged=TRUE;
- }
-
- void DoNoAddFloppy()
- {
- LONG Active;
-
- if (NewFloppy) {
- NewFloppy=FALSE;
- FreeFloppy(MainFloppy,FALSE);
- if (BackupFloppy) {
- DoMethod(LV_Floppies,MUIM_List_Insert,&BackupFloppy,1,MUIV_List_Insert_Sorted);
- AddFloppyInPlace(&FloppyList,(struct Node *)BackupFloppy);
- }
- } else {
- if (BackupFloppy) {
- get(LV_Floppies,MUIA_List_Active,&Active);
- set(LV_Floppies,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_Floppies,MUIM_List_Remove,Active);
- DoMethod(LV_Floppies,MUIM_List_Insert,&BackupFloppy,1,MUIV_List_Insert_Sorted);
- AddFloppyInPlace(&FloppyList,(struct Node *)BackupFloppy);
- }
- }
- set(WI_Contents,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- }
-
- void StopView()
- {
- set(WI_View,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- }
-
- void DoEditFloppy()
- {
- DoMethod(LV_Floppies,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainFloppy);
- if (!MainFloppy) return;
- BackupFloppy=DupFloppy(MainFloppy);
- CreateList(LV_Contents,&MainFloppy->Records);
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- set(WI_Contents,MUIA_Window_Open,TRUE);
- }
-
- void DoDeleteRecord()
- {
- LONG Response;
- LONG id = -1;
- BOOL changed = FALSE;
-
- FOREVER {
- DoMethod(LV_Contents,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_Contents,MUIM_List_GetEntry,id,&MainRecord);
- if (MainRecord->Flags & RECORD_ROOT) {
- MUI_Request(App,NULL,0,"Delete","*OK","Use 'Kill Floppy' instead");
- return;
- }
- if (MainRecord->Flags & RECORD_DIRECTORY) {
- Response=MUI_Request(App,NULL,0,"Delete"," Yes |Only Below|* No ","Delete directory and below?");
- if (Response==0)
- return;
- if (Response==1)
- DeleteBelow(MainRecord,TRUE);
- else
- DeleteBelow(MainRecord,FALSE);
- } else
- DeleteRecord(MainRecord);
-
- changed=TRUE;
- }
- if (changed) {
- CreateList(LV_Contents,&MainFloppy->Records);
- DataChanged=TRUE;
- }
- }
-
- void DoFind()
- {
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- set(WI_Match,MUIA_Window_Open,TRUE);
- set(WI_Match,MUIA_Window_ActiveObject,ST_Match);
- }
-
- void DoMatch()
- {
- STRPTR MatchString;
- LONG MatchULFlag;
- LONG DoDirsFlag;
- LONG DoKeysFlag;
- LONG KeyAndFlag;
- BOOL Found;
- LONGBITS KeyMask;
-
- get(ST_Match,MUIA_String_Contents,&MatchString);
- if (MatchString[0]==0) {
- set(WI_Match,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- return;
- }
- set(WI_Match,MUIA_Window_Open,FALSE);
- get(CM_Case,MUIA_Selected,&MatchULFlag);
- get(CM_Dirs,MUIA_Selected,&DoDirsFlag);
- get(CM_Keys,MUIA_Selected,&DoKeysFlag);
- get(CM_KeyAnd,MUIA_Selected,&KeyAndFlag);
- if (DoKeysFlag)
- KeyMask=CurKeyMask;
- else
- KeyMask=0L;
- DoMethod(LV_Files,MUIM_List_Clear,TRUE);
- Found=FindMatch(&FloppyList,MatchString,MatchULFlag,DoDirsFlag,
- KeyMask,KeyAndFlag);
- if (!Found) {
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- MUI_Request(App,NULL,0,"Find","*OK","No Match Found");
- } else
- set(WI_Files,MUIA_Window_Open,TRUE);
- }
-
- void AddMatchToList(RECORD *Record)
- {
- DoMethod(LV_Files,MUIM_List_Insert,&Record,1,MUIV_List_Insert_Bottom);
- }
-
- void DoNoMatch()
- {
- set(WI_Match,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- }
-
- void FileDispClose()
- {
- set(WI_Files,MUIA_Window_Open,FALSE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- }
-
- void DoKillFloppy()
- {
- LONG Response;
- LONG id = -1;
- BOOL changed = FALSE;
-
- FOREVER {
- DoMethod(LV_Floppies,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_Floppies,MUIM_List_GetEntry,id,&MainFloppy);
-
- Response=MUI_Request(App,NULL,0,"Kill Floppy","Yes|*No","Kill %s?",
- MainFloppy->HeadRecord->FName);
- if (Response) {
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- FreeFloppy(MainFloppy,TRUE);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- changed=TRUE;
- }
- }
- if (changed) {
- CreateList(LV_Floppies,&FloppyList);
- DataChanged=TRUE;
- }
- }
-
- void DoViewFloppy()
- {
- DoMethod(LV_Floppies,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainFloppy);
- if (!MainFloppy) return;
- CreateList(LV_View,&MainFloppy->Records);
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- set(WI_View,MUIA_Window_Open,TRUE);
- }
-
- void DoNew()
- {
- LONG Response;
-
- Response=MUI_Request(App,NULL,0,NULL,"Yes|*No","Clear All Data?");
- if (Response) {
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- FreeKeys();
- FreeAllFloppies(&FloppyList);
- DoMethod(LV_Floppies,MUIM_List_Clear,NULL);
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- DataChanged=TRUE;
- }
- }
-
- void DoRenameRecord()
- {
- DoMethod(LV_Contents,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainRecord);
- if (!MainRecord) return;
- if (MainRecord->Flags & RECORD_ROOT) {
- MUI_Request(App,NULL,0,"Rename","*OK","Cannot rename Root");
- return;
- }
- set(ST_Rename,MUIA_String_Contents,MainRecord->FName);
- set(WI_Contents,MUIA_Window_Sleep,TRUE);
- set(WI_Rename,MUIA_Window_Open,TRUE);
- set(WI_Rename,MUIA_Window_ActiveObject,ST_Rename);
- }
-
- void DoNewName()
- {
- RECORD *Record;
- STRPTR Str;
- UWORD len;
-
- get(ST_Rename,MUIA_String_Contents,&Str);
- len=strlen(Str);
- if (len) {
- Record=DupRecord(MainRecord);
- DeleteRecord(MainRecord);
- if (Record->FName)
- FreeMem(Record->FName,strlen(Record->FName)+1);
- Record->FName=AllocMem(len+1,MEMF_CLEAR);
- strcpy((char *)Record->FName,Str);
- if (AddRecordInPlace(&MainFloppy->Records,(struct Node *)Record,
- (struct Node *)Record->Parent))
- Record->Parent->Sub=Record;
- CreateList(LV_Contents,&MainFloppy->Records);
- DataChanged=TRUE;
- }
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- set(WI_Rename,MUIA_Window_Open,FALSE);
- }
-
- void DoNoNewName()
- {
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- set(WI_Rename,MUIA_Window_Open,FALSE);
- }
-
- BOOL ConfirmQuit()
- {
- return((BOOL)MUI_Request(App,NULL,0,"Quit","Yes|*No","Data Changed - Are You Sure?"));
- }
-
- char *BuildName(RECORD *Record,char *Name)
- {
- char Temp[108];
-
- Name[0]=0;
- while (!(Record->Flags & RECORD_ROOT)) {
- strcpy(Temp,Name);
- strcpy(Name,Record->FName);
- if (Record->Flags & RECORD_DIRECTORY)
- strcat(Name,"/");
- strcat(Name,Temp);
- Record=Record->Parent;
- }
- strcpy(Temp,Name);
- strcpy(Name,Record->FName);
- strcat(Name,":");
- strcat(Name,Temp);
- return(Name);
- }
-
- void CreateList(APTR LView,struct List *FList)
- {
- struct Node *Node;
-
- set(LView,MUIA_List_Quiet,TRUE);
- DoMethod(LView,MUIM_List_Clear,NULL);
- Node=FList->lh_Head;
- while (Node->ln_Succ) {
- DoMethod(LView,MUIM_List_Insert,&Node,1,MUIV_List_Insert_Bottom);
- Node=Node->ln_Succ;
- }
- set(LView,MUIA_List_Quiet,FALSE);
- }
-
- void DoAbout()
- {
- MUI_Request(App,NULL,0,NULL,"*Wow!","\33cFBase V1.06\n\33cby Amit Fridman\n\33c09.07.94");
- }
-
- void DoKeys()
- {
- STRPTR *Key;
- WORD Dummy;
-
- set(ST_KeyName,MUIA_Disabled,TRUE);
- set(WI_Keys,MUIA_Window_ActiveObject,MUIV_Window_ActiveObject_None);
- ClearKeyLView();
- InitKeyScan();
- while (Key=GetNextKey(&Dummy))
- DoMethod(LV_Keys,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- set(WI_Main,MUIA_Window_Sleep,TRUE);
- set(WI_Keys,MUIA_Window_Open,TRUE);
- if (KeysFull)
- set(BT_KeysAdd,MUIA_Disabled,TRUE);
- CopyFromKeys();
- AddKey=EditKey=FALSE;
- }
-
- void KeysAccept()
- {
- set(WI_Keys,MUIA_Window_Sleep,TRUE);
- TestKeyDelete();
- set(WI_Keys,MUIA_Window_Sleep,FALSE);
- FreeKeyCopy();
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- set(WI_Keys,MUIA_Window_Open,FALSE);
- DataChanged=TRUE;
- }
-
- void KeysClose()
- {
- CopyToKeys();
- FreeKeyCopy();
- set(WI_Main,MUIA_Window_Sleep,FALSE);
- set(WI_Keys,MUIA_Window_Open,FALSE);
- }
-
- void DoAddKey()
- {
- set(ST_KeyName,MUIA_Disabled,FALSE);
- set(ST_KeyName,MUIA_String_Contents,"");
- set(WI_Keys,MUIA_Window_ActiveObject,ST_KeyName);
- AddKey=TRUE;
- }
-
- void DoDelKey()
- {
- STRPTR KName;
- LONG Active;
-
- get(LV_Keys,MUIA_List_Active,&Active);
- if (Active!=MUIV_List_Active_Off) {
- DoMethod(LV_Keys,MUIM_List_GetEntry,Active,&KName);
- DelKeyFromList(KName);
- set(LV_Keys,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_Keys,MUIM_List_Remove,Active);
- set(ST_KeyName,MUIA_String_Contents,"");
- set(ST_KeyName,MUIA_Disabled,TRUE);
- if (KeysFull) {
- set(BT_KeysAdd,MUIA_Disabled,FALSE);
- KeysFull=FALSE;
- }
- EditKey=FALSE;
- }
- }
-
- void DoNameKey()
- {
- STRPTR KName;
- STRPTR *NewKey;
- LONG Active;
-
- if (AddKey) {
- get(ST_KeyName,MUIA_String_Contents,&KName);
- if (KName[0]==0) {
- set(ST_KeyName,MUIA_Disabled,TRUE);
- AddKey=FALSE;
- return;
- }
- NewKey=AddKeyToList(KName,&KeysFull);
- if (KeysFull)
- set(BT_KeysAdd,MUIA_Disabled,TRUE);
- DoMethod(LV_Keys,MUIM_List_Insert,NewKey,1,MUIV_List_Insert_Sorted);
- set(ST_KeyName,MUIA_String_Contents,"");
- set(ST_KeyName,MUIA_Disabled,TRUE);
- AddKey=FALSE;
- } else if (EditKey) {
- get(ST_KeyName,MUIA_String_Contents,&KName);
- if (KName[0]==0) {
- set(ST_KeyName,MUIA_Disabled,TRUE);
- EditKey=FALSE;
- return;
- }
- NewKey=ChangeKeyList(OldKey,KName);
- get(LV_Keys,MUIA_List_Active,&Active);
- set(LV_Keys,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_Keys,MUIM_List_Remove,Active);
- DoMethod(LV_Keys,MUIM_List_Insert,NewKey,1,MUIV_List_Insert_Sorted);
- set(ST_KeyName,MUIA_String_Contents,"");
- set(ST_KeyName,MUIA_Disabled,TRUE);
- EditKey=FALSE;
- }
- }
-
- void DoKeysChange()
- {
- STRPTR KName;
-
- DoMethod(LV_Keys,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&KName);
- if (KName) {
- set(ST_KeyName,MUIA_Disabled,FALSE);
- set(ST_KeyName,MUIA_String_Contents,KName);
- set(WI_Keys,MUIA_Window_ActiveObject,ST_KeyName);
- OldKey=KName;
- EditKey=TRUE;
- }
- }
-
- void DoKeySearch()
- {
- STRPTR *Key;
- WORD Dummy;
-
- DoMethod(LV_KSSrc,MUIM_List_Clear,NULL);
- DoMethod(LV_KSDest,MUIM_List_Clear,NULL);
- InitKeyScan();
- while (Key=GetNextKey(&Dummy))
- if (CurKeyMask & (1<<KeyNumber(*Key)))
- DoMethod(LV_KSDest,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- else
- DoMethod(LV_KSSrc,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- set(WI_Match,MUIA_Window_Sleep,TRUE);
- set(WI_KeySearch,MUIA_Window_Open,TRUE);
- }
-
- void KeySearchClose()
- {
- STRPTR Key;
- int i;
-
- for (i=0,CurKeyMask=0L; ; i++) {
- DoMethod(LV_KSDest,MUIM_List_GetEntry,i,&Key);
- if (!Key) break;
- CurKeyMask|=1<<KeyNumber(Key);
- }
- set(WI_Match,MUIA_Window_Sleep,FALSE);
- set(WI_KeySearch,MUIA_Window_Open,FALSE);
- }
-
- void KeySearchSToD()
- {
- STRPTR KName;
- LONG id;
-
- FOREVER {
- id=-1;
- DoMethod(LV_KSSrc,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_KSSrc,MUIM_List_GetEntry,id,&KName);
- set(LV_KSSrc,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_KSSrc,MUIM_List_Remove,id);
- DoMethod(LV_KSDest,MUIM_List_Insert,&KName,1,MUIV_List_Insert_Sorted);
- }
- }
-
- void KeySearchDToS()
- {
- STRPTR KName;
- LONG id;
-
- FOREVER {
- id=-1;
- DoMethod(LV_KSDest,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_KSDest,MUIM_List_GetEntry,id,&KName);
- set(LV_KSDest,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_KSDest,MUIM_List_Remove,id);
- DoMethod(LV_KSSrc,MUIM_List_Insert,&KName,1,MUIV_List_Insert_Sorted);
- }
- }
-
- void DoRecordKeys()
- {
- STRPTR *Key;
- WORD Dummy;
-
- DoMethod(LV_Contents,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainRecord);
- if (!MainRecord) return;
- DoMethod(LV_RKSrc,MUIM_List_Clear,NULL);
- DoMethod(LV_RKDest,MUIM_List_Clear,NULL);
- InitKeyScan();
- while (Key=GetNextKey(&Dummy))
- if (MainRecord->Keys & (1<<KeyNumber(*Key)))
- DoMethod(LV_RKDest,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- else
- DoMethod(LV_RKSrc,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- set(WI_Contents,MUIA_Window_Sleep,TRUE);
- set(WI_RecKeys,MUIA_Window_Open,TRUE);
-
- }
-
- void RecordKeysAccept()
- {
- STRPTR Key;
- LONGBITS OldKeys,NewKeys;
- LONGBITS AddMask,RemMask;
- LONG Response;
- int i;
-
- for (i=0,NewKeys=0L; ; i++) {
- DoMethod(LV_RKDest,MUIM_List_GetEntry,i,&Key);
- if (!Key) break;
- NewKeys|=1<<KeyNumber(Key);
- }
- if (MainRecord->Flags & RECORD_DIRECTORY) {
- Response=MUI_Request(App,NULL,0,"Keys","*Change|Copy|No","Propagate Keys Below?");
- if (Response) {
- if (Response==2) {
- AddMask=NewKeys;
- RemMask=NewKeys;
- } else {
- OldKeys=MainRecord->Keys;
- AddMask=~((~NewKeys) | OldKeys);
- RemMask=(~OldKeys) | NewKeys;
- }
- KeysBelow(MainRecord->Sub,AddMask,RemMask);
- }
- }
- MainRecord->Keys=NewKeys;
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- set(WI_RecKeys,MUIA_Window_Open,FALSE);
- DataChanged=TRUE;
- }
-
- void RecordKeysClose()
- {
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- set(WI_RecKeys,MUIA_Window_Open,FALSE);
- }
-
- void RecordKeysSToD()
- {
- STRPTR KName;
- LONG id;
-
- FOREVER {
- id=-1;
- DoMethod(LV_RKSrc,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_RKSrc,MUIM_List_GetEntry,id,&KName);
- set(LV_RKSrc,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_RKSrc,MUIM_List_Remove,id);
- DoMethod(LV_RKDest,MUIM_List_Insert,&KName,1,MUIV_List_Insert_Sorted);
- }
- }
-
- void RecordKeysDToS()
- {
- STRPTR KName;
- LONG id;
-
- FOREVER {
- id=-1;
- DoMethod(LV_RKDest,MUIM_List_NextSelected,&id);
- if (id==-1) break;
- DoMethod(LV_RKDest,MUIM_List_GetEntry,id,&KName);
- set(LV_RKDest,MUIA_List_Active,MUIV_List_Active_Off);
- DoMethod(LV_RKDest,MUIM_List_Remove,id);
- DoMethod(LV_RKSrc,MUIM_List_Insert,&KName,1,MUIV_List_Insert_Sorted);
- }
- }
-
- void ClearKeyLView()
- {
- DoMethod(LV_Keys,MUIM_List_Clear,NULL);
- }
-
- void AddKeyToLView(STRPTR *Key)
- {
- DoMethod(LV_Keys,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- }
-
- void DisplayFileInfo(Object *Window, Object *ListView)
- {
- UBYTE Text[140],Buffer[132];
- STRPTR *Key;
- WORD Dummy;
-
- DoMethod(ListView,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainRecord);
- if (!MainRecord) return;
- sprintf(Text,"\33iName\33n %s",BuildName(MainRecord,Buffer));
- if (MainRecord->Flags & RECORD_ROOT)
- strcat(Text," \33b[root]");
- else if (MainRecord->Flags & RECORD_DIRECTORY)
- strcat(Text," \33b(dir)");
- set(TX_FileName,MUIA_Text_Contents,Text);
- if (MainRecord->Flags & RECORD_DIRECTORY)
- strcpy(Text,"\33iSize\33n -----");
- else
- sprintf(Text,"\33iSize\33n %ld",MainRecord->Size);
- set(TX_FileSize,MUIA_Text_Contents,Text);
- if (MainRecord->FRem)
- sprintf(Text,"\33iRemark\33n %s",MainRecord->FRem);
- else
- strcpy(Text,"\33iRemark\33n -----");
- set(TX_FileRem,MUIA_Text_Contents,Text);
- DoMethod(LV_FileKeys,MUIM_List_Clear,TRUE);
- InitKeyScan();
- while (Key=GetNextKey(&Dummy))
- if (MainRecord->Keys & (1<<KeyNumber(*Key)))
- DoMethod(LV_FileKeys,MUIM_List_Insert,Key,1,MUIV_List_Insert_Sorted);
- set(WI_FileInfo,MUIA_Window_Open,TRUE);
- set(Window,MUIA_Window_Sleep,TRUE);
- ParentWindow=Window;
- }
-
- void StopFileInfo()
- {
- set(WI_FileInfo,MUIA_Window_Open,FALSE);
- set(ParentWindow,MUIA_Window_Sleep,FALSE);
- }
-
- void DoRemark()
- {
- DoMethod(LV_Contents,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&MainRecord);
- if (!MainRecord) return;
- if (MainRecord->FRem)
- set(ST_Remark,MUIA_String_Contents,MainRecord->FRem);
- else
- set(ST_Remark,MUIA_String_Contents,"");
- set(WI_Remark,MUIA_Window_Open,TRUE);
- set(WI_Contents,MUIA_Window_Sleep,TRUE);
- set(WI_Remark,MUIA_Window_ActiveObject,ST_Remark);
- }
-
- void SetRemark()
- {
- STRPTR String;
-
- get(ST_Remark,MUIA_String_Contents,&String);
- if (MainRecord->FRem) {
- FreeMem(MainRecord->FRem,strlen(MainRecord->FRem)+1);
- MainRecord->FRem=NULL;
- }
- if (strlen(String)) {
- MainRecord->FRem=AllocMem(strlen(String)+1,MEMF_CLEAR);
- strcpy(MainRecord->FRem,String);
- }
- set(WI_Remark,MUIA_Window_Open,FALSE);
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- DataChanged=TRUE;
- }
-
- void StopRemark()
- {
- set(WI_Remark,MUIA_Window_Open,FALSE);
- set(WI_Contents,MUIA_Window_Sleep,FALSE);
- }
-